#ifndef StateMonitorWidget_H
#define StateMonitorWidget_H

#include <QWidget>
#include <QTimer>
#include <armadillo>

#include "sys_data_struct.h"
#include "qcustomplot.h"
#include "NetworkInterface.h"
#include "EmotionInterface.h"
#include "WavePlotInterface.h"
#include "TreeDirectoryInterface.h"
#include "EmotionFilter.h"

namespace Ui {
class StateMonitorWidget;
}

class StateMonitorWidget : public QWidget
{
    Q_OBJECT

public:
    explicit StateMonitorWidget(const QMap<int, QString> &electrodeMap, QWidget *parent = nullptr);
    ~StateMonitorWidget();

// EmotionInterface
public:
    EmotionInterface::EmoMode getCurrentEmotion() const;
    EmotionInterface::EmoMode getVideoEmotion() const;

    void set_emoGIF();
    void hideEmoGIF();

    void setGraph_visible(int graphID, bool flag);

public slots:
    void setVideo_emotion(EmotionInterface::EmoMode mode);
    void setCurrent_emotion(EmotionInterface::EmoMode mode);
    void setCurrent_emotion(int mode);
    void emoLabel_startPlot();
    void emoLabel_stopPlot();
    void emoLabel_clearPlot();
    // void receive_eegData(const arma::mat &data);
    // void receive_eegData(const std::vector<EEG_VOLTAGE>& data);
    // void receive_eegData(const arma::cube& data);
    void plotDataUpdate(const GenEEGData& data);
    void receive_network(const arma::rowvec &);
    void networkPlot();
    void networkPlot_test();

    void waveStopPlot();
    void on_btn_clearWave_clicked(bool checked);
    void on_btn_filterSW_clicked(bool checked);

signals:
    void widgetClose(uint8_t winID);

protected:
    void closeEvent(QCloseEvent *event);


public:
    Ui::StateMonitorWidget *ui;

private:
    // plot 
    QCustomPlot *customPlot;
    EmotionInterface *emotionInf;
    NetworkInterface *networkInf;
    WavePlotInterface *waveInf;
    TreeDirectoryInterface *treeDirInf;
    
    EmotionFilter emotionfilter;
    QMap<int, QString> electrodeNameMap;
    GenEEGData orgData_beforeFilter;
    GenEEGData filtData_acc;
    

    bool Wave_filterFlag;
};

#endif // StateMonitorWidget_H